<template>
  <view class="textContainer">
    <view class="textTitle">
      <view class="titleFlag"></view><text>{{ title }}</text>
    </view>
    <view class="textContent" v-if="content.length > 0">
      <CheckMore
        :content="getFilterBrTagText(content)"
        :contentSlice="75"
      ></CheckMore>
    </view>
    <view v-else style="height: 450rpx">
      <Empty
        :baseImg="emptyImg"
        text="暂无数据"
        :fontWeight="400"
        textColor="#bfbfbf"
        class="empty"
        spacing="0"
      />
    </view>
  </view>
</template>
<script>
import CheckMore from "./checkMore";
import Empty from "@/components/Empty.vue";
import { getJobDetailNormalText } from "@/api/modules/career";
export default {
  components: {
    CheckMore,
    Empty,
  },
  props: {
    title: {
      type: String,
      default: "标题",
    },
    questionId: {
      type: String,
      default: "",
    },
    positionId: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      emptyImg: this.$imgBaseSelf + "common/empty.png",
      content: "",
    };
  },
  mounted() {
    // this.getText();
  },
  methods: {
    getText() {
      const params = {
        questionId: this.questionId,
        id: this.positionId,
      };
      getJobDetailNormalText(params).then((res) => {
        if (res.code == 200) {
          this.content =
            res.data.answer.answerContent || res.data.answer || null;
        }
      });
    },
    getFilterBrTagText(content) {
      return content.replace(/<br>/g, "\n");
    },
  },
};
</script>
<style scoped lang="scss">
.textContainer {
  margin: 24rpx 32rpx 0 32rpx;
  padding: 40rpx 34rpx 44rpx 34rpx;
  background: #ffffff;
  border-radius: 24rpx;

  .textTitle {
    display: flex;
    align-items: center;
    font-size: 32rpx;
    font-family: PingFang-SC-Heavy, PingFang-SC;
    font-weight: 800;
    color: #222222;
    line-height: 44rpx;

    .titleFlag {
      width: 8rpx;
      height: 36rpx;
      border-radius: 64rpx;
      background-color: #f75a3e;
      margin-right: 16rpx;
    }
  }

  .textContent {
    font-size: 28rpx;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #555555;
    line-height: 48rpx;
    white-space: pre-wrap;
    overflow: hidden;
    margin-top: 22rpx;
  }
}
</style>
